package com.ruoyi.project.jiaqin.supplycommentreply.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.jiaqin.supplycommentreply.domain.SupplyCommentReply;
import com.ruoyi.project.jiaqin.supplycommentreply.service.ISupplyCommentReplyService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 供应评论回复Controller
 * 
 * @author admin
 * @date 2021-02-22
 */
@Controller
@RequestMapping("/jiaqin/supplycommentreply")
public class SupplyCommentReplyController extends BaseController
{
    private String prefix = "jiaqin/supplycommentreply";

    @Autowired
    private ISupplyCommentReplyService supplyCommentReplyService;

    @RequiresPermissions("jiaqin:supplycommentreply:view")
    @GetMapping()
    public String supplycommentreply()
    {
        return prefix + "/supplycommentreply";
    }

    /**
     * 查询供应评论回复列表
     */
    @RequiresPermissions("jiaqin:supplycommentreply:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SupplyCommentReply supplyCommentReply)
    {
        startPage();
        List<SupplyCommentReply> list = supplyCommentReplyService.selectSupplyCommentReplyList(supplyCommentReply);
        return getDataTable(list);
    }

    /**
     * 导出供应评论回复列表
     */
    @RequiresPermissions("jiaqin:supplycommentreply:export")
    @Log(title = "供应评论回复", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SupplyCommentReply supplyCommentReply)
    {
        List<SupplyCommentReply> list = supplyCommentReplyService.selectSupplyCommentReplyList(supplyCommentReply);
        ExcelUtil<SupplyCommentReply> util = new ExcelUtil<SupplyCommentReply>(SupplyCommentReply.class);
        return util.exportExcel(list, "supplycommentreply");
    }

    /**
     * 新增供应评论回复
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存供应评论回复
     */
    @RequiresPermissions("jiaqin:supplycommentreply:add")
    @Log(title = "供应评论回复", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SupplyCommentReply supplyCommentReply)
    {
        return toAjax(supplyCommentReplyService.insertSupplyCommentReply(supplyCommentReply));
    }

    /**
     * 修改供应评论回复
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        SupplyCommentReply supplyCommentReply = supplyCommentReplyService.selectSupplyCommentReplyById(id);
        mmap.put("supplyCommentReply", supplyCommentReply);
        return prefix + "/edit";
    }

    /**
     * 修改保存供应评论回复
     */
    @RequiresPermissions("jiaqin:supplycommentreply:edit")
    @Log(title = "供应评论回复", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SupplyCommentReply supplyCommentReply)
    {
        return toAjax(supplyCommentReplyService.updateSupplyCommentReply(supplyCommentReply));
    }

    /**
     * 删除供应评论回复
     */
    @RequiresPermissions("jiaqin:supplycommentreply:remove")
    @Log(title = "供应评论回复", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(supplyCommentReplyService.deleteSupplyCommentReplyByIds(ids));
    }
}
